package com.md.facade;

import com.md.api.ModuleApi;
import com.md.application.service.ModuleApplicationService;
import com.md.config.Logs;
import com.md.model.page.PageResponse;
import com.md.model.system.CommonResult;
import com.md.request.ModuleRequest;
import com.md.request.QueryModuleRequest;
import com.md.response.ModuleResponse;
import com.md.value.enums.OperationEnum;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 刘骄阳
 * 2024-07-14 22:16
 */
@RestController
@RequiredArgsConstructor
public class ModuleController implements ModuleApi {
  private final ModuleApplicationService moduleApplicationService;

  @Override
  @Logs(title = "创建模块", operation = OperationEnum.INSERT)
  public CommonResult<ModuleResponse> create(final ModuleRequest request) {
    return moduleApplicationService.create(request);
  }

  @Override
  @Logs(title = "更新模块信息", operation = OperationEnum.UPDATE)
  public CommonResult<ModuleResponse> update(final ModuleRequest request) {
    return moduleApplicationService.update(request);
  }

  @Override
  @Logs(title = "查询模块详情", operation = OperationEnum.SELECT)
  public CommonResult<ModuleResponse> query(final QueryModuleRequest request) {
    return moduleApplicationService.query(request);
  }

  @Override
  @Logs(title = "查询模块列表", operation = OperationEnum.SELECT)
  public CommonResult<PageResponse<ModuleResponse>> queryList(final QueryModuleRequest request) {
    return moduleApplicationService.queryList(request);
  }
}
